package com.oneraku.service.controller;

import com.oneraku.service.domain.AddressInfo;
import com.oneraku.service.domain.UserInfo;
import com.oneraku.service.dto.MargePassword;
import com.oneraku.service.dto.VerifyCode;
import com.oneraku.service.service.IUserInfoService;
import com.oneraku.service.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: hui.ren@huberbuy.com
 * @Date: 2020/2/26 11:25
 */
@RestController
@RequestMapping("/user")
public class UserController{
    @Autowired
    private IUserInfoService userInfoService;
    /**
     * 前端登录
     * @param userInfo
     * @return
     */
    @PostMapping("/login")
    public R login(@RequestBody UserInfo userInfo) {
        return userInfoService.login(userInfo);
    }
    /**
     * 前端注册
     * @param userInfo
     * @return
     */
    @PostMapping("/register")
    public R register(@RequestBody UserInfo userInfo){ return userInfoService.register(userInfo);}
    /**
     * 注销用户
     * @return
     */
    @GetMapping("/unRegister")
    public R unRegister(){ return userInfoService.unRegister();}
    /**
     * 编辑用户信息
     * @param userInfo
     * @return
     */
    @PostMapping("/edit")
    public R edit(@RequestBody UserInfo userInfo) {
        return userInfoService.edit(userInfo);
    }
    /**
     * 通过手机号/邮箱修改密码
     * @param margePassword
     * @return
     */
    @PostMapping("/margePassword")
    public R margePassword(@RequestBody MargePassword margePassword) {
        return userInfoService.margePassword(margePassword);
    }
    /**
     * 换绑
     * @param margePassword
     * @return
     */
    @PostMapping("/changeNumber")
    public R changeNumber(@RequestBody MargePassword margePassword) {
        return userInfoService.changeNumber(margePassword);
    }
    /**
     * 我的消息
     * @param
     * @return
     */
    @GetMapping("/msg")
    public R msg() {
        return userInfoService.msg();
    }
    @GetMapping("/info")
    public R info() {
        return userInfoService.info();
    }
    /**
     * 发送验证码
     * @param verifyCode
     * @return
     */
    @PostMapping("/verifyCode")
    public R verifyCode(@RequestBody VerifyCode verifyCode) {
        return userInfoService.verifyCode(verifyCode);
    }
    /**
     * 后端登录
     * @param addressInfo
     * @return
     */
    @PostMapping("/loginAdmin")
    public R loginAdmin(@RequestBody AddressInfo addressInfo) {
        return R.ok("1");
    }
}
